<?
//引入所有子系统信息
include_once("../../../common/model/extender_import.php");
//引入系统设置
include_once("../../../common/model/setting.php");



//获取板块的设置
include_once("model/setting.php");

//查询任务板块管理员
$setting = select_one_line_all_items($table_Prefix."task_setting","nid = '1'");
$manager_user_id = explode(',',$setting['manager_user_id']);


// 权限验证 管理员查看所有人的任务 普通用户只查看自己的任务
if(in_array($_SESSION['nid'],$manager_user_id)){
    $auth = true;
}else{
    $auth = false;
}

//获取任务信息
$task=select_one_line_all_items($table_Prefix."task","nid = '".$_REQUEST['nid']."'");



//获取任务留言
$task_comment=select_lines_all_items($table_Prefix."task_comment", "nid asc", "task_id = '".$_REQUEST['nid']."' ","");

$data['employee']=select_lines_all_items($table_Prefix."employee","nid asc","status = '在职'","");


//
$_read_log=transform_2darray_in_1darray_number_as_key($task_comment,"notice_member_read");
$_read_log_str=implode(",",$_read_log);
//
////判断当前读者是否在已读名单，没有则补充进去。
//$_read_list=explode(",",$task_comment['notice_member_read']);
//
//print_r2($_read_list);

//同时写入你的阅读记录
//if(!in_array($_SESSION['nid'],$_read_list))
//{
//    $_read_log=$task_comment['notice_member_read'].",";
//    if(!$task_comment['notice_member_read'])
//    {
//        $_read_log=$task_comment['notice_member_read'];
//    }
//}

$_read_log_new_str = $_SESSION['nid'].",".$_read_log_str;
$_read_log_new     = explode(",",$_read_log_new_str);

$_member_read['ai_notice_member_read']=unique_array($_read_log_new);


$_read_sql=update_date($table_Prefix."task_comment",$_member_read,"task_id",$_REQUEST['nid']);

$query = mysql_query($_read_sql) or die ($_read_sql);
mysql_close($con);







//设置默认的任务结束时间


//获取本周周一的日期
// 获取当前时间的时间戳
$current_time = time();

// 计算本周一的Unix时间戳（偏移量是当前星期几减去1）
$weekday = date('N', $current_time) - 1;
if ($weekday == 0) {
    // 如果今天是周一，则不需要偏移
    $start_of_week = $current_time;
} else {
    // 否则，计算周一的时间戳
    $start_of_week = strtotime("-{$weekday} days", $current_time);
}

// 格式化本周一的日期为'Y-m-d'
$start_date = date('Y-m-d', $start_of_week);




// 计算本周日的Unix时间戳（偏移量是7减去当前星期几）
$weekday = date('N', $current_time);
if ($weekday == 7) {
    // 如果今天是周日，则不需要偏移
    $end_of_week = $current_time;
} else {
    // 否则，计算周日的时间戳
    $end_of_week = strtotime("next Sunday", $current_time);
}

// 格式化本周日的日期为'Y-m-d'
$end_date = date('Y-m-d', $end_of_week);





if($_REQUEST['select_startday'])
{
    $start_date=$_REQUEST['select_startday'];
}


if($_REQUEST['select_endday'])
{
    $end_date=$_REQUEST['select_endday'];
}




?>








